#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cmath>
using namespace std;
char map[1010][1010];
int dp[1010][1010];
int main()
{
    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> map[i][j];
            if (map[i][j] == '*')
            {
                dp[i + 1][j] = 1;
                dp[i][j + 1] = 1;
                dp[i - 1][j] = 1;
                dp[i][j - 1] = 1;
                dp[i][j] = 1;
            }
            if (map[i][j] == '#')
            {
                for (int x = -2; x <= 2; x++)
                {
                    for (int y = -2; y <= 2; y++)
                    {
                        if (abs(x) + abs(y) <= 2 && x+i >= 0 && j+y >= 0)dp[i + x][j + y] = 1;
                    }
                }
                dp[i][j] = 1;
            }

        }
    }
    int count = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (dp[i][j] == 0&&map[i][j]=='.')count++;
        }
    }
    cout << count << endl;
    return 0;
}